package com.pederszt.foodiary.jdo;

import java.util.List;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable
public class Item
{
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long itemId;

	@Persistent
	private String name;

	@Persistent
	private Category category;

	@Persistent
	private Integer quantity;

	@Persistent
	private QuantityType quantityType;

	@Persistent(mappedBy = "item")
	private List<ItemCost> itemCosts;

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public Long getItemId()
	{
		return itemId;
	}

	public void setItemId(Long itemId)
	{
		this.itemId = itemId;
	}

	public Category getCategory()
	{
		return category;
	}

	public void setCategory(Category category)
	{
		this.category = category;
	}

	public List<ItemCost> getItemCosts()
	{
		return itemCosts;
	}

	public void setItemCosts(List<ItemCost> itemCosts)
	{
		this.itemCosts = itemCosts;
	}

	public Integer getQuantity()
	{
		return quantity;
	}

	public void setQuantity(Integer quantity)
	{
		this.quantity = quantity;
	}

	public QuantityType getQuantityType()
	{
		return quantityType;
	}

	public void setQuantityType(QuantityType quantityType)
	{
		this.quantityType = quantityType;
	}

	public String getSearchValue()
	{
		return this.name;
	}

	@Override
	public String toString()
	{
		return this.name + " (" + this.quantity + " " + this.quantityType.getType() + ")";
	}

}
